package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealDishDTO;
import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.vo.SetmealDishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author luo20
* @description 针对表【setmeal_dish(套餐菜品关系)】的数据库操作Mapper
* @createDate 2025-07-08 19:36:46
* @Entity com.sky.entity.SetmealDish
*/
public interface SetmealDishMapper extends BaseMapper<SetmealDish> {
    /**
     * 根据菜品id和status查询有多少个套餐关联此菜品
     * @param dish
     * @return
     */
    List<SetmealDishDTO> getSetmealByConditions(Dish dish);

    /**
     * 根据套餐id获取套餐菜品关系
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> selectSetmealDishBySetmealId(@Param("setmealId") Long setmealId);

    /**
     * 新增菜品与套餐的联系
     * @param setmealDishList
     * @return
     */
    Integer saveBatchSetmealDish(@Param("setmealDishList") List<SetmealDish> setmealDishList);
    /**
     * 根据套餐id删除菜品与套餐的联系
     * @param setmealId
     * @return
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    Integer delSetmealDishById(@Param("setmealId") Long setmealId);

    /**
     * 根据套餐id批量查询套餐关联的菜品
     * @param setmealIds
     * @return
     */
    List<SetmealDishDTO> selectBathSetmealDish(@Param("setmealIds") List<Long> setmealIds);
    /**
     * 根据菜品id批量查询菜品关联的套餐
     * @param dishIdList
     * @return
     */
    List<SetmealDishDTO> getSetmealsByDishIds(@Param("dishIdList") List<Long> dishIdList);

    /**
     * 根据套餐id批量查询套餐与菜品关系数据
     * @param setmealIds
     * @return
     */
    List<SetmealDish> selectBatchSetmealDishBySetmealIds(@Param("setmealIds") List<Long> setmealIds);

    /**
     * 根据套餐id批量删除套餐与菜品关系数据
     * @param setmealIds
     * @return
     */
    Integer delBatchSetmealDishByIds(@Param("setmealIds") List<Long> setmealIds);

    /**
     * 根据套餐id查询套餐与菜品关系数据和菜品图片地址
     * @param setmealId
     * @return
     */
    @Select("select sd.*,d.image from setmeal_dish sd, dish d where sd.dish_id = d.id and sd.setmeal_id = #{setmealId}")
    List<SetmealDishVO> selectSetmealDishAndDishBySetmealId(@Param("setmealId") Long setmealId);
}




